package com.ynt.pay.common.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

/**
 * 分页
 *
 * @Author: ganbo
 * @Date: 2019/10/31 17:24
 */

@Data
@NoArgsConstructor
@AllArgsConstructor
public class PageResult<T> {

    private Integer current;    //当前页
    private Integer size;       //每页大小
    private Long total;         //总条数
    private Long pages;         //总页数
    private List<T> records;

    public PageResult(Integer current, Integer size, Long total, List<T> records) {
        this.current = current;
        this.size = size;
        this.total = total;
        this.pages = (total + size - 1) / size;
        this.records = records == null ? new ArrayList<>() : records;
    }
}
